package com.fer.tankr.models.powerups;

import org.andengine.entity.sprite.Sprite;
import org.andengine.extension.physics.box2d.PhysicsWorld;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

import com.fer.andenginemvc.api.gameObjects.GameObject;
import com.fer.andenginemvc.api.gameObjects.Powerup;
import com.fer.tankr.models.Tank;

public class Coin extends Powerup {

	public Coin(PhysicsWorld world, VertexBufferObjectManager vbom, float x,
			float y, ITextureRegion texture) {
		super(world, vbom, x, y);
		this.entity.setAlpha(0f);
		Sprite sprite = new Sprite(x, y, texture, vbom);
		sprite.setWidth(entity.getWidth());
		sprite.setHeight(entity.getHeight());
		entity.attachChild(sprite);
		
	}
	
	@Override
	public void onCollision(GameObject<?> go) {
		if (go instanceof Tank)
		{
			Tank tank = (Tank)go;
			tank.increaseCoins(1);
			die();
		}  
		
	}

}
